****Making a Connection 2008
****Michele Claibourn
****Data Preparation, 3
****Initially run in Stata 9 and Stata 10

**This file begins with the data file containing the survey data merged with ad data
**The number of ads on each issue by each candidate (Gore, Bush) aired in each DMA is merged by respondent's DMA
**Three versions of the ad data are included -- 
**   number of ads aired prior to date of respondent interview, 
**   number of ads aired in week prior to respondent interview, 
**   number of ads aired in three days prior to respondent interview

**This file creates/recodes remaining variables for analysis
**  logged ad count (7 day and accumulated), 
**  interations between issue priorities and logged ad counts
**  party identification, 
**  interactions between party and issue priority, 
**  interation between party, issue priority and logged ad counts

cd "/Users/mclaibourn/Box Sync/mpc/Politics/research/2000ads/replicationJOP"
use "survey_ads_2000v1.dta", clear

*Recode minority
recode minority 0=1 1=0

*Create PID7 with 'other' in middle, ranging from -3 to +3
gen pida=pid
replace pida=4 if pid==0
gen pid7=pida
replace pid7=-3 if pida==1
replace pid7=-2 if pida==2
replace pid7=-1 if pida==3
replace pid7=0 if pida==4
replace pid7=1 if pida==5
replace pid7=2 if pida==6
replace pid7=3 if pida==7

*Create political awareness variable, aware
alpha poltalk newsattn polint, item std gen(aware)

**Switch zeros to ones, but keep missing as missing, to allow for log transformation
*Accumulated ad variables
replace beduc=1 if beduc==0
replace geduc=1 if geduc==0
replace bhlth=1 if bhlth==0
replace ghlth=1 if ghlth==0
replace bssec=1 if bssec==0
replace gssec=1 if gssec==0
replace btax=1 if btax==0
replace gtax=1 if gtax==0

*7 day ad variables
replace b7educ=1 if b7educ==0
replace g7educ=1 if g7educ==0
replace b7hlth=1 if b7hlth==0
replace g7hlth=1 if g7hlth==0
replace b7ssec=1 if b7ssec==0
replace g7ssec=1 if g7ssec==0
replace b7tax=1 if b7tax==0
replace g7tax=1 if g7tax==0

*3 Day ad variables
replace b3educ=1 if b3educ==0
replace g3educ=1 if g3educ==0
replace b3hlth=1 if b3hlth==0
replace g3hlth=1 if g3hlth==0
replace b3ssec=1 if b3ssec==0
replace g3ssec=1 if g3ssec==0
replace b3tax=1 if b3tax==0
replace g3tax=1 if g3tax==0

**Create logged week variable, logged ad count variables
*Accumulated ad variables
gen lbeduc=log(beduc)
gen lgeduc=log(geduc)
gen lbhlth=log(bhlth)
gen lghlth=log(ghlth)
gen lbssec=log(bssec)
gen lgssec=log(gssec)
gen lbtax=log(btax)
gen lgtax=log(gtax)

*7 day ad variables
gen lb7educ=log(b7educ)
gen lg7educ=log(g7educ)
gen lb7hlth=log(b7hlth)
gen lg7hlth=log(g7hlth)
gen lb7ssec=log(b7ssec)
gen lg7ssec=log(g7ssec)
gen lb7tax=log(b7tax)
gen lg7tax=log(g7tax)

*3 day ad variables
gen lb3educ=log(b3educ)
gen lg3educ=log(g3educ)
gen lb3hlth=log(b3hlth)
gen lg3hlth=log(g3hlth)
gen lb3ssec=log(b3ssec)
gen lg3ssec=log(g3ssec)
gen lb3tax=log(b3tax)
gen lg3tax=log(g3tax)


*Center issue priority variables around 3 (midpoint, representing medium priority)
**Now 5=very high, 4=high, but not highest, 3=medium, 2=low, 1=none
gen ceducp=educp
gen cssecp=ssecp
gen chlthp=hlthp
gen ctaxp=taxp
recode ceducp 1=-2 2=-1 3=0 4=1 5=2
recode cssecp 1=-2 2=-1 3=0 4=1 5=2
recode chlthp 1=-2 2=-1 3=0 4=1 5=2
recode ctaxp 1=-2 2=-1 3=0 4=1 5=2


**Create interactions between centered issue priorities and relevant ad counts
*Bush log accumulated ad counts and issue priorities
gen hlxlbhl=chlthp*lbhlth
gen edxlbed=ceducp*lbeduc
gen ssxlbss=cssecp*lbssec
gen txxlbtx=ctaxp*lbtax

*Bush log 7 day ad counts and issue priorities
gen hlxlb7hl=chlthp*lb7hlth
gen edxlb7ed=ceducp*lb7educ
gen ssxlb7ss=cssecp*lb7ssec
gen txxlb7tx=ctaxp*lb7tax

*Bush log 3 day ad counts and issue priorities
gen hlxlb3hl=chlthp*lb3hlth
gen edxlb3ed=ceducp*lb3educ
gen ssxlb3ss=cssecp*lb3ssec
gen txxlb3tx=ctaxp*lb3tax

*Gore log ad counts and issue priorities)
gen hlxlghl=chlthp*lghlth
gen edxlged=ceducp*lgeduc
gen ssxlgss=cssecp*lgssec
gen txxlgtx=ctaxp*lgtax

*Gore log 7 day ad counts and issue priorities
gen hlxlg7hl=chlthp*lg7hlth
gen edxlg7ed=ceducp*lg7educ
gen ssxlg7ss=cssecp*lg7ssec
gen txxlg7tx=ctaxp*lg7tax

*Gore log 3 day ad counts and issue priorities
gen hlxlg3hl=chlthp*lg3hlth
gen edxlg3ed=ceducp*lg3educ
gen ssxlg3ss=cssecp*lg3ssec
gen txxlg3tx=ctaxp*lg3tax


**Create interaction between pid7 and issue priorities
gen p7xhlthp=pid7*chlthp
gen p7xeducp=pid7*ceducp
gen p7xssecp=pid7*cssecp
gen p7xtaxp=pid7*ctaxp

**Create 3-way interaction between pid7, issue priorities, and ad counts
*Bush log accumulated count
gen p7xhxbh=pid7*chlthp*lbhlth
gen p7xexbe=pid7*ceducp*lbeduc
gen p7xsxbs=pid7*cssecp*lbssec
gen p7xtxbt=pid7*ctaxp*lbtax

*Bush log 7 day count
gen p7xhxb7h=pid7*chlthp*lb7hlth
gen p7xexb7e=pid7*ceducp*lb7educ
gen p7xsxb7s=pid7*cssecp*lb7ssec
gen p7xtxb7t=pid7*ctaxp*lb7tax

*Bush log 3 day count
gen p7xhxb3h=pid7*chlthp*lb3hlth
gen p7xexb3e=pid7*ceducp*lb3educ
gen p7xsxb3s=pid7*cssecp*lb3ssec
gen p7xtxb3t=pid7*ctaxp*lb3tax

*Gore log accumulated count
gen p7xhxgh=pid7*chlthp*lghlth
gen p7xexge=pid7*ceducp*lgeduc
gen p7xsxgs=pid7*cssecp*lgssec
gen p7xtxgt=pid7*ctaxp*lgtax

*Gore log 7 day count
gen p7xhxg7h=pid7*chlthp*lg7hlth
gen p7xexg7e=pid7*ceducp*lg7educ
gen p7xsxg7s=pid7*cssecp*lg7ssec
gen p7xtxg7t=pid7*ctaxp*lg7tax

*Gore log 3 day count
gen p7xhxg3h=pid7*chlthp*lg3hlth
gen p7xexg3e=pid7*ceducp*lg3educ
gen p7xsxg3s=pid7*cssecp*lg3ssec
gen p7xtxg3t=pid7*ctaxp*lg3tax

**Create interaction between pid7 and ad counts
*Bush log accumulated count
gen p7xlbhl=pid7*lbhlth
gen p7xlbed=pid7*lbeduc
gen p7xlbss=pid7*lbssec
gen p7xlbtx=pid7*lbtax

*Bush log 7 day count
gen p7xlb7hl=pid7*lb7hlth
gen p7xlb7ed=pid7*lb7educ
gen p7xlb7ss=pid7*lb7ssec
gen p7xlb7tx=pid7*lb7tax

*Bush log 3 day count
gen p7xlb3hl=pid7*lb3hlth
gen p7xlb3ed=pid7*lb3educ
gen p7xlb3ss=pid7*lb3ssec
gen p7xlb3tx=pid7*lb3tax

*Gore log accumulated count
gen p7xlghl=pid7*lghlth
gen p7xlged=pid7*lgeduc
gen p7xlgss=pid7*lgssec
gen p7xlgtx=pid7*lgtax

*Gore log 7 day count
gen p7xlg7hl=pid7*lg7hlth
gen p7xlg7ed=pid7*lg7educ
gen p7xlg7ss=pid7*lg7ssec
gen p7xlg7tx=pid7*lg7tax

*Gore log 3 day count
gen p7xlg3hl=pid7*lg3hlth
gen p7xlg3ed=pid7*lg3educ
gen p7xlg3ss=pid7*lg3ssec
gen p7xlg3tx=pid7*lg3tax


save "survey_ads37acc_2000v2.dta", replace
save "survey_ads_2000v2.dta", replace
